package com.xiaobingby.easyuisys.controller;

import com.xiaobingby.common.controller.BaseController;
import com.xiaobingby.easyuisys.entity.Tree;
import com.xiaobingby.easyuisys.service.IPermissionService;
import com.xiaobingby.easyuisys.service.IRoleService;
import com.xiaobingby.sys.entity.User;
import com.xiaobingby.sys.service.IUserService;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 李磊
 * @date 2019/4/30
 */
@Controller("easyuiIndexController")
@RequestMapping("/easyui")
public class IndexController extends BaseController {

    @Autowired
    IRoleService roleService;
    @Autowired
    IPermissionService permissionService;

    @GetMapping("/index")
    public String index(Model model){
        model.addAttribute("roleNames",roleService.listUserRoleName(this.getCurrentLoginId()));
        model.addAttribute("username",this.getCurrentLoginUsername());
        return "/easyui/index";
    }

    @GetMapping("/userMenus")
    @ResponseBody
    public List<Tree> getUserMenus(){
        return permissionService.getUserMenu(this.getCurrentLoginId());
    }


}
